<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>签约网</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <link rel="stylesheet" type="text/css" href="../css/lawyer.css" />
    <script type="text/javascript" src="../script/api.js"></script>
    <script type="text/javascript" src="../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../script/mobile.js"></script>
    <script type="text/javascript" src="../script/lawyer.js"></script>
</head>
<body>
<div id="secHeader">
  <header class="header">
      <a href="javascript:void(0);" onclick="api.closeWin()" class="back_btn"><img src="../image/head-fanhui.png" alt=""></a>
      <h2>委托详情</h2>
      <!--<a href="javascript:void (0);" class="share_btn"><img src="../image/share_icon.png" alt=""></a>-->
  </header>
</div>

<section class="bid_time">
    <p id='lasttime'>投标截止时间：2019-11-18  14:45</p>
</section>
<section class="ask_article">
    <div class="userInfo">
        <img src="../image/userimg1.jpg" alt="" id='icon'>
        <div class="userName">
            <h6 id='phone'>135****7574</h6>
            <span id='time'>2019-11-25  18:51</span>
        </div>
    </div>
    <div class="comment_info">
        <p id='content'>租房子签了一年合同，但是销售人员说住不够可以提前一个月联系他，他帮我找下家，现在没住够一年我搬走了，他们完全不管了，我该怎么办？</p>
    </div>
</section>

<section class="entrust_list">
    <ul>
        <li>
            <div class="entrust">
                <p>委托报价</p>
                <p id='price'>3000.00-5000.00元</p>
            </div>
            <div class="entrust">
                <p>委托保证金</p>
                <p id='margin'>100元</p>
            </div>
        </li>
        <li>
            <div class="entrust">
                <p>委托需求类型</p>
                <p>普通代理</p>
            </div>
            <div class="entrust">
                <p>案件类型</p>
                <p>一般民事</p>
            </div>
        </li>
    </ul>
</section>

<section class="comment_section">
    <div class="news_title">
        <h2>信托律师</h2>
    </div>
    <div class="comment_list">
        <ul id='con'>
            <!-- <li>
                <div class="userInfo">
                    <img src="../image/userimg1.jpg" alt="">
                    <div class="userName">
                        <h6>张岳伦律师 <i>LV.6</i></h6>
                        <span>2019-11-11  14:45</span>
                    </div>
                </div>
                <div class="service_kinds">
                    <dl>
                        <dd>遗产纠纷</dd>
                        <dd>劳动仲裁</dd>
                        <dd>人身损害</dd>
                        <dd>合同纠纷</dd>
                        <dd>家产分割</dd>
                    </dl>
                </div>
            </li> -->

        </ul>
    </div>
</section>

<section class="fixed_ask">
    <a href="javascript:;" class="ask_btn2 bid_btn3">我要投标</a>
</section>

<section class="fixed_bid">
    <div class="bid_section">
        <h2>请填写信托报价</h2>
        <p>委托报价 <em id='price1'>3000.00-5000.00</em>元</p>
        <input type="text" placeholder="输入金额" id='money'>
        <span>信托报价的高低也会对中标结果产生影响</span>
        <button class="sure_btn" type="submit" onclick="jionwt()">确定</button>
    </div>
</section>

</body>

<script>
    var para
    var lastime=0
    var maxprice=0
    apiready = function () {
$api.fixStatusBar( $api.dom('#secHeader') );
      api.setStatusBarStyle({
          style: 'light'
      });


        para=api.pageParam

        var p={id:para.id}
        api.ajax({
                url: webSiteUrl+'/app/public/wtdetail',
                method: 'post',
                data: {
                    values: p
                }
            }, function(ret, err) {


                if(ret.code==200){


                    var tj=ret.data.uinfo;
                    $('#icon').attr('src',webSiteUrl+tj.icon);
                    $('#phone').html(tj.phone);


                    var info=ret.data.info;

                    $('#time').html(info.time);
                    $('#content').html(info.content);
                    $('#price').html(info.price+'元');
                    $('#price1').html(info.price);
                    $('#margin').html(info.margin+'元');
                    $('#lasttime').html('投标截止时间：'+info.lasttime);
                    lastime=info.last_time
                    maxprice=info.maxprice

                    if(info.over==1){
                       $('.fixed_ask').hide()
                    }

                    html = "";
                    var tj=ret.data.list;
                    if(tj != null){

for(var i=0;i<tj.length;i++){
html+='<li><div class="userInfo"><img src="'+webSiteUrl+tj[i].icon+'" alt=""><div class="userName"><h6>'+tj[i].nickname+'律师 <i>LV.6</i></h6><span>'+tj[i].time+'</span></div></div><div class="service_kinds"><dl>';

    if(tj[i].label.length>0){
        for(var j=0;j<tj[i].label.length;j++){
            html+='<dd>'+tj[i].label[j]+'</dd>';
        }
    }
html+='</dl></div></li>';
}
                        $('#con').html(html);
                    }else{
                        $('#con').html('<p style="text-align:center">暂无信托</p>');
                    }



                }
            });

    };




    function jionwt(){
        var timestamp = (new Date()).getTime();
        if(timestamp>lasttime){
            alert('投标已截止，请查看其他案源');return;
        }
        var money=$('#money').val();
        if(!/^[0-9]+$/.test(money)){
            alert('金额必须是数字');return;
        }else if(money>maxprice){
            alert('投标金额不能大于委托报价');return;
        }
        var p={token:token,id:para.id,money:money};
        api.ajax({
                url: webSiteUrl+'/app/user/joinwt',
                method: 'post',
                data: {
                    values: p
                }
            }, function(ret, err) {
                api.hideProgress();

                if(ret.code==200){

                    html = "";
                    var tj=ret.data;
                    if(tj != null){


html+='<li><div class="userInfo"><img src="'+webSiteUrl+tj.icon+'" alt=""><div class="userName"><h6>'+tj.nickname+'律师 <i>LV.6</i></h6><span>'+tj.time+'</span></div></div><div class="service_kinds"><dl>';

    if(tj.label.length>0){
        for(var j=0;j<tj.label.length;j++){
            html+='<dd>'+tj.label[j]+'</dd>';
        }
    }
html+='</dl></div></li>';
                    }
                    if($('#con li').length>0){
                        $('#con').prepend(html);
                    }else{
                        $('#con').html(html);
                    }


                    alert(ret.msg)
                }else{

                    alert(ret.msg)


                }
            });

    }

    function askdetail(id){
        api.openWin({
            name: 'askdetail',
            url: 'askdetail.html',
            reload:true,
            pageParam: {
                id: id,

            }
        });
    }

    //投标
    $(".fixed_ask").click(function () {
        //TODO 隐藏
        // var result = loginCheck();
        var result = true
        if(result == false){
          return false;
        }
        $(".fixed_bid").fadeToggle();
        $(".fixed_bid .bid_section").animate({
            'top': '0',
            'opacity': '1'
        },400);
    });
    $(".bid_section .sure_btn").click(function () {
        $(".fixed_bid").fadeToggle();
        $(".fixed_bid .bid_section").animate({
            'top': '-4rem',
            'opacity': '0'
        },400);
    });
</script>
</html>
